home *** CD-ROM | disk | FTP | other *** search
- /*
- * getset.c - code to check that we have all the files,
- * etc needed to run
- */
- #include "RevRdist.h"
- #include "desktop.h"
- #include "volops.h"
-
-
- /*
- *=========================================================================
- * getSet - make sure we have enough information to proceed
- * returns: 0 if all set
- * <> 0 if something missing
- * Quit may or may not be set
- *=========================================================================
- */
-
- OSErr
- getSet()
- {
- OSErr error;
- cnode_t *cn; /* ptr to fi->f_info */
- file_info_t *fi; /* temp ptr into File_list[] */
- prefs_t *pp; /* ptr to working prefs structure */
- StringHandle sh; /* temp string handle */
- StringPtr sp; /* ptr into mi Data area */
- StringPtr st; /* string temp */
- int t; /* temp */
- Integer vol; /* volume reference temp */
- HParamBlockRec hpb; /* for GetVInfo, etc calls */
- Str255 s; /* string temp */
- AFPVolMountInfo mi; /* server volume information */
-
- desktop_end();
- ServerVol = 0;
- fi = &File_list[FL_PREF];
- cn = &fi->f_info;
- if (fi->f_set)
- {
- /*
- * If prefs file from launch, fetch values from it.
- * The file had better be there.
- */
- if (fi->f_launch)
- {
- fi->f_launch = false; /* get only one shot */
- error = prefFFetch (fi);
- if (error)
- {
- sh = fi->f_path;
- HLock ((Handle) sh);
- panic (true, E_PREFS, *sh, nil);
- HUnlock ((Handle) sh);
- return error;
- }
- prefMerge (P_WORK, true);
- }
- }
- /*
- * Figure out where the server master folder is.
- * Its name (absolute path) is a preferences resource.
- * If mounting/unmounting of server volumes is allowed, set up
- * mi structure
- */
- pp = &Prefs[P_WORK];
- sh = pp->p[PS_MASTF];
- if (!sh)
- {
- panic (true, E_NOSERVER, nil);
- return E_NOSERVER;
- }
- COPYPS (*sh, s);
- ZERO(mi);
- mi.length = sizeof(mi);
- mi.media = AppleShareMediaType;
- if (!(Flags & PF_NOMOUNT))
- {
- /*
- * Need to temporarily logically shorten master folder name to just
- * volume name
- */
- t = s[0]; /* current length */
- st = (StringPtr)strchr((char *)s+1, ':');
- if (st)
- (*sh)[0] = st - (s+1);
- sp = (StringPtr)mi.AFPData;
- #define COPYPREF(ii,ee) \
- sh = pp->p[ii]; \
- if (sh && (st = *sh) && st[0] && st[0] < 32) \
- COPYPS(st, sp); \
- mi.ee = sp - (StringPtr)(&mi); \
- sp += 32;
-
- COPYPREF(PS_ZONE, zoneNameOffset);
- if (sp[-32+0] == 0)
- {
- sp[-32+1] = '*'; /* supply default zone name */
- sp[-32+0] = 1;
- }
- COPYPREF(PS_SRVR, serverNameOffset);
- COPYPREF(PS_MASTF, volNameOffset);
- st[0] = t; /* restore length */
- COPYPREF(PS_USER, userNameOffset);
- COPYPREF(PS_PASS, userPasswordOffset);
- #undef COPYPREF
- }
- error = accessMaster (s, &mi);
- Clue0 = "\pgetSet";
- if (error)
- {
- ClueID = error;
- if (error == fnfErr || error == nsvErr || error == dirNFErr)
- panic (true, E_NOSERVER, s, nil);
- else if (error == afpAccessDenied)
- panic (true, E_NOACCESS, s, nil);
- else
- panic (true, E_SYS, Clue0, "\paccessMaster", nil);
- }
- if (error || Quit)
- return error;
- fi = &File_list[FL_MAST];
- cn = &fi->f_info;
- error = getInfoByPath (s, fi);
- if (error)
- {
- ClueID = error;
- panic (true, E_SYS, Clue0, "\pgetInfoByPath", nil);
- }
- if (error || Quit)
- return error;
- ServerVol = fi->f_vol;
- ServerRoot = fi->f_info.dirID;
- ZERO (hpb);
- s[0] = 0;
- hpb.volumeParam.ioNamePtr = s;
- hpb.volumeParam.ioVRefNum = ServerVol;
- error = PBHGetVInfo (&hpb, false);
- if (error)
- {
- ClueID = error;
- panic (true, E_SYS, Clue0, "\pPBHGetVInfo", nil);
- }
- ZERO(ServerVIB);
- hpb.ioParam.ioBuffer = (Ptr) &ServerVIB;
- hpb.ioParam.ioReqCount = sizeof (ServerVIB);
- error = PBHGetVolParms (&hpb, false);
- if (error && error != paramErr)
- {
- ClueID = error;
- panic (true, E_SYS, Clue0, "\pPBHGetVolParms (S)", nil);
- }
- // /*
- // * Set master folder as default volume
- // */
- // error = SetVol (s, ServerVol);
- /*
- * If we don't have a config file yet, locate it via preferences
- */
- fi = &File_list[FL_DIST];
- cn = &fi->f_info;
- if (! fi->f_set)
- {
- sh = Prefs[P_WORK].p[PS_DISTF];
- if (!sh)
- {
- panic (true, E_DISTF, (SP)"", nil);
- return fnfErr;
- }
- HLock ((Handle) sh);
- fi->f_vol = 0;
- error = getInfoByPath (*sh, fi);
- if (error)
- {
- panic (true, E_DISTF, *sh, nil);
- HUnlock ((Handle) sh);
- return error;
- }
- HUnlock ((Handle) sh);
- }
- /*
- * okay, now find the volume to update.
- * If FINDUPD flag, it is first writeable, non-floppy, non-weird volume
- * else it is the volume containing the preferences file, if present,
- * else the volume containing a distribution file used to launch us,
- * else the volume with the the blessed folder.
- */
- error = 0;
- if (Flags & PF_FINDUPD)
- error = findWvol (s, FF_WRITE|FF_NOSONY|FF_NOXFS|FF_NOASHARE, &vol);
- else if (File_list[FL_PREF].f_set)
- vol = File_list[FL_PREF].f_vol;
- else if (File_list[FL_DIST].f_launch)
- vol = File_list[FL_DIST].f_vol;
- else
- vol = BlessedWD;
- fi = &File_list[FL_ROOT];
- fi->f_ref = vol;
- fi->f_info.ctype = C_FOLDER;
- s[0] = 0;
- if (error == 0)
- error = getInfoByPath (s, fi);
- if (error)
- {
- panic (true, E_NOVOL, nil);
- return E_NOVOL;
- }
- ClientVol = fi->f_vol;
- ClientRoot = fsRtDirID;
- COPYPS (fi->f_info.name, ClientVolName);
- /*
- * Make sure that client is HFS volume
- * Save volume size information
- */
- ZERO (hpb);
- s[0] = 0;
- hpb.volumeParam.ioNamePtr = s;
- hpb.volumeParam.ioVRefNum = ClientVol;
- PBHGetVInfo (&hpb, false);
- if (hpb.volumeParam.ioVSigWord == 0xD2D7)
- {
- panic (true, E_MFS, CurApName, s, nil);
- return E_MFS;
- }
- ClientSp = (unsigned long)(unsigned)hpb.volumeParam.ioVFrBlk
- * (unsigned)hpb.volumeParam.ioVAlBlkSiz;
- ClientClp = hpb.volumeParam.ioVClpSiz;
- ClientClpM = ClientClp - 1; /* assumes ClientClp is power of 2 */
- /*
- * Check if the client volume is writeable
- * If not, warn and set ListOnly
- */
- if (!(Flags & PF_LISTONLY) && (hpb.volumeParam.ioVAtrb & 0x8080))
- {
- warning (E_LISTONLY, s, nil);
- Flags |= PF_LISTONLY;
- }
- ZERO(ClientVIB);
- hpb.ioParam.ioBuffer = (Ptr) &ClientVIB;
- hpb.ioParam.ioReqCount = sizeof (ClientVIB);
- error = PBHGetVolParms (&hpb, false);
- if (error && error != paramErr)
- {
- ClueID = error;
- panic (true, E_SYS, Clue0, "\pPBHGetVolParms (C)", nil);
- }
- error = desktop_start();
- if (error)
- return error;
- /*
- * Create/access junk folder.
- * If fails, just warn about it.
- */
- error = makeJunk ();
- return error;
- }